using System.Diagnostics;
using System.Text;

namespace TypograFix
{
  /// <summary>
  /// Utility class which builds HTML files.
  /// </summary>
  public class HtmlBuilder
  {
    /// <summary>
    /// The builder used to build HTML.
    /// </summary>
    private readonly StringBuilder sb;

    /// <summary>
    /// Initializes a new instance of the <see cref="HtmlBuilder"/> class.
    /// </summary>
    public HtmlBuilder()
    {
      sb = new StringBuilder();
    }

    /// <summary>
    /// Appends the specified object as text.
    /// </summary>
    /// <param name="obj">The object.</param>
    /// <returns></returns>
    public HtmlBuilder Append(object obj)
    {
      sb.Append(obj);
      Trace.WriteLine(string.Format("HtmlBuilder appended {0}, contents now {1}", obj, sb));
      return this;
    }

    /// <summary>
    /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
    /// </summary>
    /// <returns>
    /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
    /// </returns>
    public override string ToString()
    {
      return sb.ToString();
    }
  }
}